/* @file ${file_name}
 *
 * (c) ${year} Yell Adworks Ltd.  Newlands House,
 * Caxton Way, Thornburgh Road, Eastfield, Scarborough, U.K.
 *
 * All rights reserved.
 *
 * @(#) $$Id: BaseEntityDao.java,v 1.3 2011/01/05 15:46:27 swright Exp $$
 */
package com.myschool.server.dao.support;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.myschool.server.model.BaseEntity;

/**
 * Generic BaseEntity DAO interface.
 * 
 * @param <T> a class handled by this interface.
 * 
 * @version $Id: BaseEntityDao.java,v 1.3 2011/01/05 15:46:27 swright Exp $
 */
@Repository
public interface BaseEntityDao<T extends BaseEntity> extends GenericDao<T> {
	/**
	 * Generic method used to get an object by entity id
	 * 
	 * @param identity the unique identify used to get the object
	 * @return the correct object from the database
	 */
	T get(Long identity);

	/**
	 * Find object by name.
	 * Use only for classes where name is unique, as it insists on 0 or 1 matches!
	 *
	 * @param name the name to find
	 * @return the appropriate object
	 */
	T findByName(String name);

	/**
	 * Get a list of objects who's names contain the given substring.
	 * Use only for classes where name field is available!
	 *
	 * @param searchFor the substring to match names with
	 * @return the appropriate list of objects
	 */
	List<T> searchByNameSubstring(String searchFor);
}
